<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Userudid extends Model
{
    //
    protected $table = 'user_udid';

    protected $primaryKey = 'id';
    
    protected $fillable = array('uid', 'udid','content');
    
    protected function getDateFormat()
    {
    	return date(time());
    }
    
    static function checkStrangeLand($udid){
    	$user_udids = Userudid::where('uid','=',$user->uid)->getAll()->toArray();
    	$udids = array();
    	if(!empty($user_udids)){
    		foreach($user_udids as $k => $v){
    			$udids[] = $v['udid'];
    		}
    		if(!in_array($udid, $udids)){
    			return false;
    		}
    	}else{
    		$user_udid = new Userudid();
    		$user_udid->uid = $user->uid;
    		$user_udid->udid = $udid;
    		$user_udid->created = time();
    		$user_udid->save();
    		return true;
    	}
    }

}
